//
//  GJEdgeLabel.m
//  YDGJ
//
//  Created by 黄卫 on 17/2/24.
//  Copyright © 2017年 huangwei. All rights reserved.
//

#import "GJEdgeLabel.h"

@interface GJEdgeLabel ()

@property (assign, nonatomic) UIEdgeInsets edgeInsets;

@end

@implementation GJEdgeLabel

-(instancetype)initWithFrame:(CGRect)frame edgeInsets:(UIEdgeInsets)egeInsets
{
    if (self = [super initWithFrame:frame]) {
        self.edgeInsets = egeInsets;
    }
    return self;
}

-(CGRect)textRectForBounds:(CGRect)bounds limitedToNumberOfLines:(NSInteger)numberOfLines
{
    CGRect rect = [super textRectForBounds:UIEdgeInsetsInsetRect(bounds,self.edgeInsets) limitedToNumberOfLines:numberOfLines];
    
    rect.origin.x -= self.edgeInsets.left;
    rect.origin.y -= self.edgeInsets.top;
    rect.size.width += self.edgeInsets.left + self.edgeInsets.right;
    rect.size.height += self.edgeInsets.top + self.edgeInsets.bottom;
    return rect;
}
- (void)drawTextInRect:(CGRect)rect
{
    [super drawTextInRect:UIEdgeInsetsInsetRect(rect, self.edgeInsets)];

}
@end
